(function(){
	var c_id = '#login_box';
	var b_url = 'http://www.kekenet.com/bianji/newcms/admin/index.php/';
	var l_un = '<li class="c_u_sanjiao"><a rel="forward" href="http://u.kekenet.com/index.php?m=member&c=index&a=login">登录</a>　<a href="http://dipan.kekenet.com/do.php?ac=alex">注册</a> </li>'; // unlogin
	var l_ed = '<li class="c_u_sanjiao"><a href="http://dipan.kekenet.com" target="_blank">Hi,<span id="username"></span></a>　<a rel="forward" href="http://u.kekenet.com/index.php?m=member&c=index&a=logout">注销</a> </li>'; // logined
	
	var g = function(u){
		top.location.href = u + '&forward=' + location.href + '&siteid=1';
	};
	var p = function(d){
		$(c_id).html(d.s == 1 ? l_ed : l_un);
		if(d.s == 1) {
			$(c_id).find('#username').html(d.username);
		}
		$(c_id).find('a[rel=forward]').live('click', function(){
			top.location.href = $(this).attr('href') + '&forward=' + encodeURIComponent(location.href) + '&siteid=1';
			return false;
		});
	};
	var c = function(){ // check
		$.getJSON(b_url + '/login.check', p);
	};
	var d = function(url, d) { // do login || register
		$.post(url, d, p, 'json');
	};
	$(document.body).ready(c);
})();